// 商品模块
import {createSlice} from "@reduxjs/toolkit";

const goodsSlice = createSlice({
    name:"goods",
    initialState:{
        goodsList:[]
    },
    reducers:{
        // 添加商品
        addGoods(state,{payload}){
            state.goodsList.unshift({
                id:Math.random().toString(36).slice(2),
                ...payload
            })
        }
    }

})
const goods = goodsSlice.reducer;
export const {addGoods} = goodsSlice.actions;
export default goods;